<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
<script src="bootstrap/jquery/jquery-3.4.1.min.js"></script>
<script src="bootstrap/js/bootstrap.min.js"></script>
<style>
	.table tr th{
		text-align:center;
	} 
	.table tr td {
	height:48.8px
	text-align: center;
	}
	.table tr td span{
	line-height:32px;
	text-align: center;
		/* height:76px;
		line-height:60px */
	} 
	.table tr td .btn{
		background-color:#0AA5E2;
	}
</style>
</head>
<body>
	<jsp:include page="header.jsp"></jsp:include>
	<div class="wrap">
		<div class="main" style="min-height: 600px">
			<div class="container">
				<div class="row clearfix">
					<div class="col-md-12 column">
						<div class="pag-nav">
							<ul class="p-list" style="font-size:24px">
								<li><a href="index.jsp" >首页</a></li>
								<li class="act">|</li>
								<li class="act">订单页</li>
							</ul>
						</div>
						<form action="order" method="post" class="form-horizontal"
							role="form">
							<div style="min-height: 427.4px;background-color: #D9EDF7"> 
							<table class="table">
								<thead>
									<tr>
										<th>订单号</th>
										<th>订单金额</th>
										<th>下单时间</th>
										<th>预定时间</th>
										<th>订单类型</th>
										<th>订单状态</th>
										<th>用户地址</th>
										<th>站点地址</th>
										<th>操作</th>
									</tr>
								</thead>

								<tbody>

									<c:forEach items="${orders}" var="ord">
										<tr class="info">
											<td><span class="tb_products">${ord.oid }</span> <input
												type="hidden" value="" class="form-control" id="pimage"
												name="pimage" /></td>
											<td><span class="tb_products">${ord.total}元</span> <input
												type="hidden" value="" class="form-control" name="pname"
												id="pname" /></td>
											<td><span class="tb_products"><fmt:formatDate
														value="${ord.submittime}" pattern="yyyy-MM-dd HH:mm:ss" /></span>
												<input type="hidden" value="20" class="form-control"
												id="pprice" name="pprice" /></td>
											<td><span class="tb_products"><fmt:formatDate
														value="${ord.destinetime}" pattern="yyyy-MM-dd HH:mm:ss" /></span>
												<input type="hidden" value="" class="form-control"
												id="weight" name="weight" /></td>
											<td><span class="tb_products">${ord.okind}</span> <input
												type="hidden" value="" class="form-control tprice"
												name="tprice" id="tprice" /></td>
											<td><span class="tb_products">${ord.ostatus}</span> <input
												type="hidden" value="" class="form-control tprice"
												name="tprice" id="tprice" /></td>
											<td><span class="tb_products">${ord.uaddress}</span> <input
												type="hidden" value="" class="form-control tprice"
												name="tprice" id="tprice" /></td>
											<td><span class="tb_products">${ord.waddress}</span> <input
												type="hidden" value="" class="form-control tprice"
												name="tprice" id="tprice" /></td>
											<td>
												 <span class="tb_products"><button  type="button" class="btn btn-success" 
								onclick="window.location.href='item?action=toOrderItem&oid=${ord.oid }'">详情</button></span> 
												 <span class="tb_products"><button  type="button"  class="btn btn-success btn_cancel">取消</button></span>

											</td>
										</tr>
									</c:forEach>
								</tbody>
							</table>
							</div>
						</form>
						${pageTool }
					</div>
				</div>
			</div>
		</div>
	</div>
	<div class="footer">
		<div class="wrap">
			<div class="contact-section">
				<div class="col-md-4 follow text-left">
					<h3>关注我们</h3>
					<p>这里有更多的信息</p>
					<div class="social-icons">
						<i class="twitter"></i> <i class="facebook"></i> <i
							class="googlepluse"></i> <i class="pinterest"></i> <i
							class="linkedin"></i>
					</div>
				</div>
				<div class="col-md-4 subscribe text-left">
					<h3>订阅我们</h3>
					<p>直接在收件箱中获取最新的更新和优惠。</p>
					<input type="text" class="text" value="" onfocus="this.value = '';"
						onblur="if (this.value == '') {this.value = '';}"> <input
						type="submit" value="Subscribe">
				</div>
				<div class="col-md-4 help text-right">
					<h3>需要帮助？</h3>
					<p>这里有更多的信息</p>
					<a href="#">联系我们</a>
				</div>
				<div class="clearfix"></div>
			</div>
			
			<div class="copyright text-center">
				<p>
					2020 All rights reserved by <a href="#"> 扔了吗？</a>
				</p>
			</div> 
		</div>
	</div>
	<script>
	 $(function() {
		$(".btn_cancel").click(function() {
			var status=$(this).parent().parent().prev().prev().prev().children(":first").html();
			if(status!="已下单"){
				alert("当前订单无法取消！")
				return false;
			}
			var msg = "您真的确定要取消吗？\n\n请确认！"; 
			if (confirm(msg)==false)  return false; 
			
			var oid =$(this).parent().parent().parent().children(":first").children(":first").html();
			$(this).parent().parent().prev().prev().prev().children(":first").html("已取消");
			$.ajax({
				url : "order",
				type : "post",
				data : {
					"oid" : oid,
					"action":"cancelOrder_ajax"
				},
				dataType : "text",
				success : function(result) {
					if (result == '1') {
						//alert("改变成功！");
					} else {
						alert("未改变成功！");
					}
				},
				error : function() {
					alert("系统发生错误，请联系管理员！");
				}
			})
		}) 	
	}) 
	</script>
</body>
</html>